﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace MVCExtension.FrameWork
{
    public class MasterHelper
    {
        /// <summary>
        /// 判断用户是否登陆系统
        /// </summary>
        public static Boolean IsLogin
        {
           
            get { return System.Web.HttpContext.Current.User.Identity.IsAuthenticated; }
        }

        /// <summary>
        /// 登录用户ID,每次登陆随机产生，MD5加密后保存
        /// </summary>
        public static string LoginID
        {
            get { return RequestHelper.GetCookie("LoginID"); }
            set { RequestHelper.WriteCookie("LoginID", value); }
        }


        /// <summary>
        /// 登陆用户名称ID
        /// </summary>
        public static string MasterName
        {
            get { return SecurityHelper.Decrypt(RequestHelper.GetCookie("master_name")); }
            set { RequestHelper.WriteCookie("master_name", SecurityHelper.Encrypt(value)); }
        }


        /// <summary>
        /// 登陆用户昵称
        /// </summary>
        public static string Nickname
        {
            get { return SecurityHelper.Decrypt(RequestHelper.GetCookie("master_nickname")); }
            set { RequestHelper.WriteCookie("master_nickname", SecurityHelper.Encrypt(value)); }
        }


        /// <summary>
        /// 用户权限
        /// </summary>
        public static string UsergroupId
        {
            get { return SecurityHelper.Decrypt(RequestHelper.GetCookie("UsergroupId")); }
            set { RequestHelper.WriteCookie("UsergroupId", SecurityHelper.Encrypt(value)); }
        }
        


        /// <summary>
        /// 登陆用户进行操作记录ID
        /// </summary>
        public static string Luruid
        {
            get { return SecurityHelper.Decrypt(RequestHelper.GetCookie("master_luruid")); }
            set { RequestHelper.WriteCookie("master_luruid", SecurityHelper.Encrypt(value)); }
        }



         
        /// <summary>
        /// 设置用户登录IP
        /// </summary>
        public static String LoginIP { get; set; }
    }
}
